package my.hnb.android.ultils;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import android.annotation.SuppressLint;

@SuppressLint("SimpleDateFormat")
public class DateUtil {
	
	public final static String DEFAULT_FORMAT = "yyyyMMdd HHmmss";
	public final static String TIME_UPDATE = "dd/MM/yyy HH:mm:ss";
	public static final String DATE_FORMAT_NOW = "dd-MM-yyyy HH:mm:ss";
	
	
	public static String now() {
		Calendar cal = Calendar.getInstance();
		SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
		return sdf.format(cal.getTime());
	}
	
	public static String now(String format) {
		Calendar cal = Calendar.getInstance();
		SimpleDateFormat sdf = new SimpleDateFormat(format);
		return sdf.format(cal.getTime());
	}

	
	public static String convertDateTimeWithFormat(Date date, String format) {
		if (StringUtil.isNullOrEmpty(format)) {
			SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
			return sdf.format(date);
		} else {
			SimpleDateFormat sdf = new SimpleDateFormat(format);
			return sdf.format(date);
		}
	}
}
